package com.koo.modules.b2b.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.koo.common.utils.MyStrUtil;
import com.koo.common.utils.PageUtils;
import com.koo.common.utils.Query;
import com.koo.modules.b2b.dao.B2bPrefixDao;
import com.koo.modules.b2b.entity.B2bPrefixEntity;
import com.koo.modules.b2b.service.B2bPrefixService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Map;

@Slf4j
@Service
public class B2bPrefixServiceImpl extends ServiceImpl<B2bPrefixDao, B2bPrefixEntity> implements B2bPrefixService {


    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        Object key = params.get("key");
        LambdaQueryWrapper<B2bPrefixEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(MyStrUtil.isNotEmpty(key), B2bPrefixEntity::getPrefix, key)
        ;

        IPage<B2bPrefixEntity> page = this.page(
                new Query<B2bPrefixEntity>().getPage(params),
                queryWrapper
        );

        return new PageUtils(page);
    }

}